{include file="common/_meta" /}
<title></title>
</head>

<body>
	<nav class="breadcrumb">
		<i class="Hui-iconfont">&#xe67f;</i> 首页
		<span class="c-gray en">&gt;</span>会员管理
		<span class="c-gray en">&gt;</span> 会员列表
		<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);"
		 title="刷新">
			<i class="Hui-iconfont">&#xe68f;</i>
		</a>
	</nav>
	<div class="page-container">
		<div class="text-c">
			<form class="Huiform" method="get" action="">
				状态：
				<span class="select-box inline">
					<select name="status" class="select">
						<option value="">全部</option>
						<option value="1">在线</option>
						<option value="0" style="color:red;">离线</option>
					</select>
				</span>
				<!-- 排序（降序）：
				<span class="select-box inline">
					<select name="order" class="select">
						<option value="">--默认--</option>
						<option value="create_time">-注册时间</option>
						<option value="acc_balance">-分红金额</option>
						<option value="acc_coin">-账户金币</option>
					</select>
				</span> -->
				<input type="text" class="input-text" style="width:250px" placeholder="会员姓名、手机号" id="" name="keywords" value="{$Request.get.keywords|default=''}">
				<input type="text" class="input-text" style="display: none;" placeholder=""  name="page" value="1">
				<button type="submit" class="btn btn-success radius" id="" name="">
					<i class="Hui-iconfont">&#xe665;</i> 搜索</button>
			</form>
		</div>
		<div class="cl pd-5 bg-1 bk-gray mt-20">
			<a class="btn btn-primary radius" onclick="userAdd(1)" href="javascript:;">
				<i class="Hui-iconfont"></i> 添加会员</a>
			<span class="r">共有数据：
				<strong>{$list->total()}</strong> 条</span>
		</div>
		<div class="mt-20">
			<table class="table table-border  table-hover table-bg table-sort">
				<thead>
					<tr class="text-c">
						<th width="25">
							<input type="checkbox" name="" value="">
						</th>
						<th>编号</th>
						<th>推荐人</th>
						<th>会员信息</th>
						<th>所在区域</th>
						<th>糖果币</th>
						<th>KR币</th>
						<th>回购币</th>
						<th>商城币</th>
						<th>信息查看</th>
						<th>注册时间</th>
						<th>状态</th>
						<th width="10%">操&nbsp;&nbsp;&nbsp;&nbsp;作</th>
					</tr>
				</thead>
				<tbody>
					{volist name='list' id="vo"}
					<tr class="text-c">
						<td>
							<input type="checkbox" value="1" name="">
						</td>
						<td>{$i}</td>
						<td>{$vo.userParent.name}:{$vo.userParent.tel}</td>
						<td>
							<a href="?pid={$vo.uid}">{$vo.name} : {$vo.tel}</a>
						</td>
						<td>{$vo.area_name}</td>
						<td>
							<a href="javascript:;" onclick="add(this,{$vo.uid},'tg_coin','调整[{$vo.name}]糖果币')">{$vo.tg_coin}</a>
						</td>
						<td>
							<a href="javascript:;" onclick="add(this,{$vo.uid},'kr_coin','调整[{$vo.name}]kr币')">{$vo.kr_coin}</a>
						</td>
						<td>
							<a href="javascript:;" onclick="add(this,{$vo.uid},'hg_coin','调整[{$vo.name}]回购币')">{$vo.hg_coin}</a>
						</td>
						<td>
							<a href="javascript:;" onclick="add(this,{$vo.uid},'sc_coin','调整[{$vo.name}]商城币')">{$vo.sc_coin}</a>
						</td>
						<td>
							<a href="{:url('Deal/cmlist')}?uid={$vo.uid}"> 糖果机</a> |
							<a href="{:url('Deal/zhuan')}?uid={$vo.uid}"> 交易列表</a> | 
							<a href="{:url('userAcclog')}?page=1&uid={$vo.uid}"> 账户明细</a>
						</td>	

						<td>{$vo.create_time}</td>
						<td class="td-status">
							{if condition="$vo.status eq 1"}
							<span class="label label-success radius">已启用</span>
							{else/}
							<span class="label label-error radius">已禁用</span>
							{/if}
						</td>
						<td class="td-manage">
							{if condition="$vo.status eq 1"}
							<a style="text-decoration:none" onClick="us_stop(this,{$vo.uid})" href="javascript:;" title="禁用">
								<i class="Hui-iconfont">&#xe631;</i>
							</a>
							{else/}
							<a style="text-decoration:none" onClick="us_start(this,{$vo.uid})" href="javascript:;" title="激活">
								<i class="Hui-iconfont">&#xe6a7;</i>
							</a>
							{/if} &nbsp;&nbsp;
							<a style="text-decoration:none" class="ml-5" onClick="resetpwd(this,{$vo.uid})" href="javascript:;" title="重置密码">
								<i class="Hui-iconfont">&#xe63f;</i>
							</a>
							 &nbsp;&nbsp;
							<a style="text-decoration:none" href="javascript:;" onClick="editInfo(this, {$vo.uid})" title="编辑">
								<i class="Hui-iconfont">&#xe6df;</i>
							</a>

						</td>
					</tr>
					{/volist}
				</tbody>
			</table>
			<div class="pages" style="margin:20px;float: right; ">{$list->render()}</div>
		</div>
		<!-- 修改会员 -->
		<div id="user_edit" class="modal fade" style="margin: 0 auto;" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
		 aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content radius">
					<div class="modal-header">
						<h3 class="modal-title"></h3>
						<a class="close" data-dismiss="modal" aria-hidden="true" href="javascript:void();">×</a>
					</div>
					<div class="modal-body">
						<article class="page-container" style="padding-right: 10%;">
							<form action="" method="post" class="form form-horizontal" id="form-user-edit">
								<div class="row cl hidden">
									<label class="form-label col-xs-4 col-sm-3"></label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="text" name="uid" id="uid" class="input-text" placeholder="" autocomplete="off" value="0">
									</div>
								</div>
								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">推荐人：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="text" name="p_tel" id="p_tel" class="input-text" autocomplete="off" placeholder="手机号">
									</div>
								</div>
								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">会员姓名：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="text" name="name" id="name" class="input-text" autocomplete="off">
									</div>
								</div>
								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">手机号：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="text" name="tel" id="tel" class="input-text" autocomplete="off">
									</div>
								</div>
								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">开户银行：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="text" name="bank" id="bank" class="input-text" autocomplete="off">
									</div>
								</div>
								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">银行卡号：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="text" name="banknum" id="banknum" class="input-text" autocomplete="off">
									</div>
								</div>

								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">支付宝：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="text" name="alipay" id="alipay" class="input-text" autocomplete="off">
									</div>
								</div>
								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">微信：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="text" name="wechat" id="wechat" class="input-text" autocomplete="off">
									</div>
								</div>
								<div class="row cl">
									<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
										<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
										<input class="btn btn-primary radius hidden" type="reset" value="&nbsp;&nbsp;重置&nbsp;&nbsp;" id="reset">
									</div>
								</div>
							</form>
						</article>
					</div>
				</div>
			</div>
		</div>
		<!-- 添加 -->
		<div id="user_add" class="modal fade" style="margin: 0 auto;" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
		 aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content radius">
					<div class="modal-header">
						<h3 class="modal-title"></h3>
						<a class="close" data-dismiss="modal" aria-hidden="true" href="javascript:void();">×</a>
					</div>
					<div class="modal-body">
						<article class="page-container" style="padding-right: 10%;">
							<form action="" method="post" class="form form-horizontal" id="form-user-add">
								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">会员姓名：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="text" name="name" class="input-text" autocomplete="off">
									</div>
								</div>
								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">手机号：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="text" name="tel" class="input-text" autocomplete="off">
									</div>
								</div>
								<!-- 选择区域 -->
								<div class="row cl">
                                    <label class="form-label col-xs-4 col-sm-3">所在区域</label>
                                    <div class="formControls col-xs-8 col-sm-9">
                                        <span class="select-box inline">
									<select name="province" class="select" id="province">
										<option value="">---</option>
										{volist name="province" id="vo"}
											<option value="{$vo.p_code}">{$vo.name}</option>
										{/volist}
									</select>
									</span> &nbsp;
                                        <span class="select-box inline">
									<select name="city" class="select" id="city"> 
										<option value="">---</option>
									</select>
									</span> &nbsp;
                         
                                    </div>
                                </div>
								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">开户银行：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="text" name="bank" class="input-text" autocomplete="off">
									</div>
								</div>
								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">银行卡号：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="text" name="banknum" class="input-text" autocomplete="off">
									</div>
								</div>

								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">支付宝：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="text" name="alipay" class="input-text" autocomplete="off">
									</div>
								</div>
								<div class="row cl">
									<label class="form-label col-xs-4 col-sm-3">微信：</label>
									<div class="formControls col-xs-8 col-sm-9">
										<input type="text" name="wechat" class="input-text" autocomplete="off">
									</div>
								</div>
								<div class="row cl">
									<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
										<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
									</div>
								</div>
							</form>
						</article>
					</div>
				</div>
			</div>
		</div>

	</div>
	{include file="common/_footer" /}
	<!--请在下方写此页面业务相关的脚本-->
	<script type="text/javascript">
		$('select[name="status"]').val({$Request.get.status});
		$('select[name="level"]').val({$Request.get.level});
		// 获取城市
		$("#province").change(function() {
	        var code = $(this).val();
	        $.get("{:url('Agent/getCity')}", { 'p_code': code }).success(function(data) {
	            var html = '<option value="0">---</option>';
	            $.each(data.city, function(index, value) {
	                html += '<option value="' + value.c_code + '">' + value.name + '</option>';
	            });
	            $('#city').html(html);
	            $('#dist').html('<option value="0">---</option>');
	        });
	    });


		function us_stop(obj, id) {
			layer.confirm('确认要停用吗？', function (index) {
				$.ajax({
					type: 'POST',
					url: "{:url('User/index')}?act=status",
					data: { 'uid': id },
					dataType: 'json',
					success: function (data) {
						if (data.code) {
							$(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="us_start(this,' + id + ')" href="javascript:;" title="启用"><i class="Hui-iconfont">&#xe6e1;</i></a>');
							$(obj).parents("tr").find(".td-status").html('<span class="label label-defaunt radius">已禁用</span>');
							$(obj).remove();
						}
						layer.msg(data.msg, { icon: 6, time: 1000 });
					},
					error: function (data) {
						console.log(data.msg);
					},
				});
			});
		}
		function us_start(obj, id) {
			layer.confirm('确认要启用吗？', function (index) {
				$.ajax({
					type: 'POST',
					url: "{:url('User/index')}?act=status",
					data: { 'uid': id },
					dataType: 'json',
					success: function (data) {
						if (data.code) {
							$(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="us_stop(this,' + id + ')" href="javascript:;" title="禁用"><i class="Hui-iconfont">&#xe631;</i></a>');
							$(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已启用</span>');
							$(obj).remove();
						}
						layer.msg(data.msg, { icon: 6, time: 1000 });
					},
					error: function (data) {
						console.log(data.msg);
					},
				});
			});
		}
		function resetpwd(obj, id) {
			layer.confirm('确认要重置吗？', function (index) {
				$.ajax({
					type: 'POST',
					url: "{:url('User/index')}?act=reset",
					data: { 'uid': id },
					dataType: 'json',
					success: function (data) {
						layer.msg('密码已重置!', { icon: 1, time: 1000 });
					},
					error: function (data) {
						console.log(data.msg);
					},
				});
			});
		}
		function add(obj, id, type, title) {
			var o_num = parseFloat($(obj).text());
			layer.prompt({ title: title, }, function (num) {
				if (num) {
					$.post("{:url('User/index')}?act=acc", { uid: id, num: num, type: type }).success(function (data) {
						layer.msg(data.msg);
						if (data.code) {
							$(obj).text(o_num + parseFloat(num));
						}
					})
				}
			});
		}
		// 


		// 添加会员
		function userAdd() {
			$("#user_add").modal("show");
		}

		$("#form-user-add").find('input:submit').click(function () {
			$.post("{:url('User/index')}?act=add", $("#form-user-add").serialize()).success(function (data) {
				layer.msg(data.msg);
				if (data.code) {
					setTimeout(function () {
						history.go(0);
					}, 1000);
				}
			});
			return false;
		});

		// 修改用户信息
		function editInfo(obj, uid) {
			$.post("{:url('user/index')}?act=get", { uid: uid }, function(data){
				if (data) {
					$('#uid').val(uid);
					$('#name').val(data.name);
					$('#tel').val(data.tel);
					$('#bank').val(data.bank);
					$('#banknum').val(data.banknum);
					$('#alipay').val(data.alipay);
					$('#wechat').val(data.wechat);

					$("#user_edit").modal("show");
				}
			});
		}

		$("#form-user-edit").find('input:submit').click(function () {
			$.post("{:url('User/index')}?act=edit", $("#form-user-edit").serialize()).success(function (data) {
				layer.msg(data.msg);
				if (data.code) {
					setTimeout(function () {
						history.go(0);
					}, 1000);
				}
			});
			return false;
		});

	</script>
</body>

</html>